<template>
	<view class="content">
		<view class="cu-list menu margin-tb-sm margin-top-lg itemstyle">
			<view class="cu-item arrow" @click="toUrl('/pages/user/avatar')">
				<view class="content">
					<image src="@/static/images/ui-15/1.png" style="width: 40rpx;height: 40rpx"></image>
					<text>头像</text>
				</view>
				<view class="action">
					<view class="cu-avatar-group">
						<view class="cu-avatar round sm" :style="'background-image: url('+avatar+');'"></view>
					</view>
				</view>
			</view>
			<view class="cu-item itemstyle">
				<view class="content">
					<image src="@/static/images/ui-15/2.png" style="width: 40rpx;height: 40rpx"></image>
					<text>用户名</text>
				</view>
				<view class="action">{{ userinfo.username }}</view>
			</view>
			<view class="cu-item arrow itemstyle" @click="toUrl('/pages/user/updateuserinfo')">
				<view class="content">
					<image src="@/static/images/ui-15/3.png" style="width: 40rpx;height: 40rpx"></image>
					<text>昵称</text>
				</view>
				<view class="action">{{ userinfo.nickname }}</view>
			</view>
			<view class="cu-item itemstyle">
				<view class="content">
					<image src="@/static/images/ui-15/4.png" style="width: 40rpx;height: 40rpx"></image>
					<text>会员级别</text>
				</view>
				<view class="action">{{userinfo.level_name}}</view>
			</view>
<!-- 			<view class="cu-item">
				<view class="content">
					<image src="@/static/images/ui-15/1.png" style="width: 40rpx;height: 40rpx"></image>
<text class="text-gray cuIcon-group_fill"></text>
					<text>团队等级</text>
				</view>
				<view class="action">
					<view class="text-grey text-sm">
						<text>{{ userinfo.team_name }}</text>
					</view>
				</view>
			</view> -->
		</view>
		
		<view class="cu-list menu margin-tb-sm itemstyle">
			<view class="cu-item arrow" @click="toUrl('/pages/user/repasswd?type=login')">
				<view class="content">
					<image src="@/static/images/ui-15/5.png" style="width: 50rpx;height: 40rpx;margin-right: 20upx"></image>
					<text>登录密码</text>
				</view>
			</view>
			<view class="cu-item arrow" @click="toUrl('/pages/user/repasswd?type=pay')">
				<view class="content">
					<image src="@/static/images/ui-15/6.png" style="width: 35rpx;height: 40rpx;margin-right: 35upx"></image>
					<text>支付密码</text>
				</view>
			</view>
			<view class="cu-item arrow" @click="toUrl('/pages/user/certification')">
					<view class="content">
						<image src="@/static/images/ui-15/7.png" style="width: 50rpx;height: 40rpx;margin-right: 20upx"></image>
						<text>实名认证</text>
					</view>
					<view class="action"></view>
				</view>
				<view class="cu-item">
					<view class="content">
						<image src="@/static/images/ui-15/8.png" style="width: 40rpx;height: 40rpx"></image>
						<text>电话号码</text>
					</view>
					<view class="action">{{ userinfo.phone }}</view>
				</view>
			
		</view>
		
		<view class="cu-list menu margin-tb-sm itemstyle">
			<view class="cu-item arrow" @click="toUrl('/pages/address/index')">
				<view class="content">
					<image src="@/static/images/ui-15/9.png" style="width: 40rpx;height: 40rpx"></image>
					<text>我的收货地址</text>
				</view>
			</view>
			<view class="cu-item arrow" @click="toUrl('/pages/bank/index')">
				<view class="content">
					<image src="@/static/images/ui-15/10.png" style="width: 40rpx;height: 40rpx"></image>
					<text>银行卡</text>
				</view>
			</view>
		</view>
		
		<view class="cu-list menu margin-tb-sm itemstyle">
			<view class="cu-item">
				<view class="content">
					<image src="@/static/images/ui-15/11.png" style="width: 40rpx;height: 40rpx"></image>
					<text>APP版本</text>
				</view>
				<view class="action">1.3.38</view>
			</view>
<!-- 			<view class="cu-item">
				<view class="content">
					<image src="@/static/images/ui-15/1.png" style="width: 40rpx;height: 40rpx"></image>
<text class="text-gray cuIcon-info"></text>
					<text>注册地址</text>
				</view>
				<view class="action">
					<view class="text-grey text-sm">
						<text>{{ userinfo.reg_ip }}</text>
					</view>
				</view>
			</view> -->
		</view>
		
		<view class="cu_btn" @click="dologout()">退出登录</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				avatar:'/static/default.png',
				userinfo:[]
			};
		},
		onLoad: function (option) {
			this.helper.checkLogin();
			this.getData();
		},
		
		methods: {
			getData:function(){
				//获取基础参数
				// uni.showLoading({
				// 	title:"数据加载中",
				// 	mask:true
				// })
				var info = uni.getStorageSync("userinfo");
				let timestamp = this.helper.now();
				let sign = this.helper.setSign(['username='+info.username,'token='+info.token,'timestamp='+timestamp]);
				this.helper.req({
					api:"getUserInfo",
					timestamp:timestamp,
					data:{username:info.username,token:info.token},
					header:{sign:sign},
					method:'GET',
				}).then(res=>{
					this.userinfo = res.data.data.userinfo;
					if(this.userinfo.avatar){
						this.avatar = this.weburl + this.userinfo.avatar;
					}
					setTimeout(() => {
						uni.hideLoading();
					}, 300);
				})
			},
			//链接
			toUrl:function(e){
				uni.navigateTo({
					url: e,
				});	
			},
			dologout:function(e){
				uni.showModal({
					title: "提示",
					content: "确认退出？",
					showCancel: true,
					confirmText: "确定",
					success:function(res){
						if(res.confirm){
							uni.clearStorageSync('userinfo');
							uni.reLaunch({
								url:"../login/login"
							})
						}
					}
				})
			},
		},
	};
</script>

<style lang="scss">
	page{
		background-color: #dde9fb;
	}
	.itemstyle{
		    background-color: #fff;
		    //opacity: 0.3;
	}
	.cu_btn{
		background: linear-gradient( 180deg, #9dc1ff 0%, #508ffd 100%);
		height: 50px;
		width: 80vw;
		color: #fff;
		line-height: 50px;
		font-size: 16px;
		border-radius: 30px;
		text-align: center;
		margin:40rpx auto;
	}
</style>